home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / Prograph Classic 2.6.1 / Prograph Reference Manual / Prograph Reference 5-7 / Prograph Reference 5-7.rsrc / TEXT_170.txt < prev    next >
Encoding:
Text File  |  1995-10-25  |  10.6 KB  |  386 lines

  1.  
  2. Strings
  3.  
  4. Pascal‚Äôs ‚Äúpacked array of characters‚Äù‚Äîused to represent Macintosh resource types, for example‚Äîis not a string, but an integer.  It can be represented by enclosing the data within single quotes, as in 'ICN#'. The format primitive can be used for proper display of such data.
  5.  
  6.  
  7. _________________________________________________
  8.  
  9.                                                   "in"     *330*
  10.  
  11.  
  12. Input names: aString;  SubString;  [StartIndex]
  13.  
  14. Input types: string;  string;  [integer]
  15.  
  16. Defaults: StartIndex = 1
  17.  
  18. Output names: FoundIndex
  19.  
  20. Output types: integer
  21.  
  22. Description:     If SubString occurs in aString at or after position StartIndex, FoundIndex is the index of the first character of this occurrence in aString. Otherwise, FoundIndex is 0. StartIndex must be positive.
  23.  
  24. Note:     If SubString is an empty string, FoundIndex returns 1.
  25.  
  26. See also:  "length", "join"
  27.  
  28.  
  29. _________________________________________________
  30.  
  31.                                           "join"     *330*
  32.  
  33.  
  34. Input names: String1; [String2;  ...]
  35.  
  36. Input types: string;  [string;  ...]
  37.  
  38. Output names: Result
  39.  
  40. Output types: string
  41.  
  42. Description:     Result is the concatenation of String1, ‚Ķ.
  43.  
  44. See also:  "in", "length"
  45.  
  46.  
  47. _________________________________________________
  48.  
  49.                                    "length"     *331*
  50.  
  51.  
  52. Input types: string
  53.  
  54. Output types: integer
  55.  
  56. Description:     Length is the number of characters in aString.
  57.  
  58. See also:  "in", "join"
  59.  
  60.  
  61. _________________________________________________
  62.  
  63.                                    byte-length     *331*
  64.  
  65.  
  66. Input types: string
  67.  
  68. Output types: integer
  69.  
  70. Description: Returns the length of the specified string in bytes
  71.  
  72.  
  73. _________________________________________________
  74.  
  75.                                         format      *331*
  76.  
  77.  
  78.  
  79. Input names: FormatString;  [Data Item1;  ...; Data ItemN]
  80.  
  81. Input types: string;  [<any type> ;  ...; <any type>]
  82.  
  83. Output names: Formatted String
  84.  
  85. Output types: string
  86.  
  87. Description:  Creates a Formatted String from FormatString and the Data Items which are to be formatted. FormatString consists of arbitrary text interspersed with format items.  Each Data Item is formatted according to the specification of its associated format item as described in the following Backus-Naur form.
  88.  
  89.  <format>         ::= {<string><format item><string>}
  90.  
  91.  <format item>       ::= \\ | \<numeric item>\ | \<alpha item>\
  92.  
  93.  <alpha item>       ::= <alpha space> | <justifier><alpha             space>
  94.  
  95.  <numeric item>     ::= <numeric type> | <sign><numeric             type> | 
  96.          <justifier><numeric type> |                <justifier><sign><numeric type>
  97.  
  98.  <numeric type>      ::= <base space> | <integer space> | <real            space>
  99.  
  100.  <real space>       ::= <integer space>.<integer space>
  101.  
  102.  <base space>      ::= <base>#<integer space>
  103.  
  104.  <integer space>      ::= {0-9}
  105.  
  106.  <alpha space>       ::= {a-z | A-Z}
  107.  
  108.  <base>         ::= 2-32
  109.  
  110.  <sign>         ::= + | -
  111.  
  112.  <justifier>        ::= < | >
  113.  
  114.  <string>         ::= {any character except \}
  115.  
  116.  (Note: curly brackets denote possible repetition of the enclosed symbols zero or more times. A hyphen denotes a range of characters, for example a-z means all characters from a to z.)
  117.  
  118.  Each format item is:
  119.  
  120.  o delimited by backslashes 
  121.  
  122.  o contains any number of alpha spaces or integer spaces, but     not both
  123.  
  124.  o contains at most one of < and >
  125.  
  126.  o contains at most one of + and -
  127.  
  128.  o contains at most one of . and #
  129.  
  130.  o cannot contain alpha spaces if it contains . or #. 
  131.  
  132.  < means justify the item to the left. This is the default for text.
  133.  
  134.  > means justify the item to the right. This is the default for numbers.
  135.  
  136.  + means always display the sign of a number.
  137.  
  138.  - for an integer or based integer means format the Data Item as an unsigned integer. 
  139. For a real - means format the absolute value of the Data Item.
  140.  
  141.  # means format the number as a based integer.
  142.  
  143.  . means format the number as a floating point number. 
  144.  
  145.  If the Data Item is a string then the total number of alpha spaces in the format item determines the number of characters output to the Formatted String irrespective of the length of the Data Item string. When the format item does not define sufficient space for a textual data item, characters are truncated from the right.
  146.  
  147.  If the Data Item is a number, the number of characters in the Formatted String equals the number of integer spaces plus any of the characters +, -, . or # that the format requires.  When the format item does not define sufficient space for a numeric data item, asterisks are output to the Formatted String.  If the format item specifies a floating point number then digits which follow the decimal point define the precision of the number.
  148.  
  149.  If the Data Item is of any other type then it can only be formatted using an empty format item, that is, \\ .  The Data Item will be unparsed into a string according to the standard rules of the Prograph parser. 
  150.  
  151.  An empty format item can also be used to format strings of arbitrary length or integers or reals into strings of variable length.
  152.  
  153. Examples:
  154.  
  155. Format Item                   Input            Output (n = space)    
  156.  
  157. test \\ of                  23                "test 23 of"    
  158.  
  159. \aaaaaa\                "waloon"           "waloon"    
  160.  
  161. \aaaaaa\                  "loon"              "loon n n"    
  162.  
  163. \>aaaaaa\                "loon"              "n n loon"    
  164.  
  165. \aaaa\                     'STR#'                "STR#"    
  166.  
  167. \aa\                        'STR#'                 "R#"    
  168.  
  169. \a\                          'STR#'                 "#"    
  170.  
  171. \a\                           9                      "     "  (a tab character)    
  172.    
  173. \99\                         9                         "n9"    
  174.  
  175. \99\                        -9                         "-9"    
  176.  
  177. \+99\                       9                        "n+9"    
  178.  
  179. \+99\                      -9                        "n-9"    
  180.  
  181. \-99\                        9                        "n9"    
  182.  
  183. \-99\                      -9                         "**"  (not enough space)    
  184.  
  185. \-9999999999\      -9                  "4294967287"    
  186.  
  187. \99.99\               1.236                     "1.24"    
  188.  
  189. \99.99\               333.33                 "*****"  (not enough space)    
  190.    
  191. \16#9999\             19                   "16#0013"    
  192.  
  193. \16#9999\           -19                   "-16#013"    
  194.  
  195. \16#99\                19                       "16#13"    
  196.  
  197. \16#9\                  19                     "****"  (not enough space)    
  198.  
  199. See also:  from-string, to-string
  200.  
  201.  
  202. _________________________________________________
  203.  
  204.                                     from-ascii     *334*
  205.  
  206.  
  207. Input types: list of integer
  208.  
  209. Output types: string
  210.  
  211. Description:     aString is sequence of characters, the ASCII representations of which are the integers in aList.
  212.  
  213. See also:  to-ascii, to-string, from-string, tokenize
  214.  
  215.  
  216. _________________________________________________
  217.  
  218.                                    from-string     *334*
  219.  
  220.  
  221. Input types: string
  222.  
  223. Output types: <not a class or Macintosh type> | Point | Rect
  224.  
  225. Description:     Data is the value textually represented by aString.
  226.  
  227. See also:  to-string, to-ascii, from-ascii, tokenize
  228.  
  229.  
  230. _________________________________________________
  231.  
  232.                                                integer-to-string    *335*
  233.  
  234.  
  235. Input type: integer
  236.  
  237. Output type: string
  238.  
  239. Description: String is the four character string representation of Integer.
  240.  
  241. Example: If Integer = 16#54455854 ( ‚ÄúTEXT‚Äù ), then String = ‚ÄúTEXT‚Äù.
  242.  
  243. See also: string-to-integer
  244.  
  245.  
  246. _________________________________________________
  247.  
  248.                                                middle     *335*
  249.  
  250.  
  251. Input types: string;  integer;  integer
  252.  
  253. Output types: string
  254.  
  255. Description:     OutString is the N characters of InString beginning at Index.
  256.  
  257. See also:  prefix, suffix, "in"
  258.  
  259.  
  260. _________________________________________________
  261.  
  262.                                            munge-string    *335*
  263.  
  264.  
  265. Input types: string; string [; string‚Ķ]
  266.  
  267. Output types: string
  268.  
  269. Description: Search Main for ‚Äò^#‚Äô combinations, where # is from 0-9, and replace with the appropriate parameter text.
  270.  
  271.  
  272. _________________________________________________
  273.  
  274.                                        prefix     *335*
  275.  
  276.  
  277. Input types: string;  integer
  278.  
  279. Output types: string;  string
  280.  
  281. Description:     Prefix is the leftmost N characters of InString. Suffix is the remaining characters.
  282.  
  283. Example:    The following example extracts the first and last names; the space character separates the two names.  The second root of the prefix primitive returns the last name, while suffix is used to strip the trailing blank from the first name.
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296. See also:  middle, suffix, "in"
  297.  
  298.  
  299.  
  300. _________________________________________________
  301.  
  302.                              string-length    *336*
  303.  
  304.  
  305. Input types: string
  306.  
  307. Output types: integer
  308.  
  309. Description: Returns the character length of the given string.
  310.  
  311.  
  312. _________________________________________________
  313.  
  314.                                  string-to-integer    *336*
  315.  
  316.  
  317. Input type: string
  318.  
  319. Output type: integer
  320.  
  321. Description: Integer is the integer represented by the four character string.
  322.  
  323. Example: If String = ‚ÄúTEXT‚Äù, then Integer = 16#54455854 ( ‚ÄòTEXT‚Äô ).
  324.  
  325. See also: integer-to-string
  326.  
  327.  
  328. _________________________________________________
  329.  
  330.                                suffix     *337*
  331.  
  332.  
  333. Input types: string;  integer
  334.  
  335. Output types: string;  string
  336.  
  337. Description:     Suffix is the rightmost N characters of InString. Prefix is the remaining characters.
  338.  
  339. See also:  middle, prefix, "in"
  340.  
  341.  
  342. _________________________________________________
  343.  
  344.                                 to-ascii     *337*
  345.  
  346.  
  347. Input types: string
  348.  
  349. Output types: list
  350.  
  351. Description:     aList is the list of integers that are the ASCII representations of the characters of aString.
  352.  
  353. See also:  from-ascii, from-string, tokenize
  354.  
  355.  
  356. _________________________________________________
  357.  
  358.                               to-string     *337*
  359.  
  360.  
  361. Input types: <not a class or Macintosh type> | Point | Rect
  362.  
  363. Output types: string
  364.  
  365. Description:     aString is the textual representation of Data.
  366.  
  367. See also:  from-string, to-ascii, from-ascii, tokenize
  368.  
  369.  
  370. _________________________________________________
  371.  
  372.                               tokenize     *338*
  373.  
  374.  
  375. Input types: string
  376.  
  377. Output types: list
  378.  
  379. Description:     aString is divided into tokens according to the following grammar, in such a way that the leftmost tokens are as long as possible.  The list Tokens consists of pairs of the form (Type Token), where Token is one of the tokens found and Type is an integer from 1 to 5 representing token types <reserved>, <string>, <atom>, <integer>, and <real> respectively.  If a substring is encountered that cannot be parsed into any of these token types, Tokens is terminated with the pair (0 NULL).
  380.  <token> ::= <reserved> | <quoted string> | <atom> |            <integer> | <real>
  381.  <reserved> ::= ( | ) | [ | ] | { | } 
  382.  
  383.  The remaining nonterminals are defined in the ‚ÄúValues‚Äù section in appendix IV, ‚ÄúSyntax and Semantics.‚Äù
  384.  
  385. See also:  to-ascii, from-ascii, to-string, from-string
  386.